
var/list/LevelControllers = list()

proc/CreateLevelControllers()
	LevelControllers.len = world.maxz
	world.log << "Init: Entering Creating LevelControllers maxz is [LevelControllers.len]"
	for(var/i=1, i < world.maxz+1, i++)
		world.log << "Init: Creating LC at [i]"
		LevelControllers[i] = new /LevelController(i)
	for(var/i=1, i < DUNGEON_START, i++)
		var/LevelController/LC = LevelControllers[i]
		LC.CombatAllowed = 0


LevelController
	var
		zlevel as num
		TurnController/MonsterController/MonsterController
		CombatAllowed=1 as num
	New(_zlevel as num)
		if(!_zlevel) del src
		zlevel = _zlevel
		if(LevelControllers.len < zlevel) LevelControllers.len = zlevel
		LevelControllers[zlevel] = src
		var/TurnController/MonsterController/MC = new(zlevel)
		MonsterController = MC
		spawn(rand(1, 125)) Start()
		return 1
	proc
		Start()
			if(zlevel >= DUNGEON_START)
				MonsterController.PopulateLevel()
			spawn() ManageLevel()
		ManageLevel()
			set background = 1
			if(zlevel >= DUNGEON_START)
				MonsterController.SpawnMonsters()
			spawn(700)
				ManageLevel()